import os

import yaml

#追加写入
def write_yaml(filename, data):
    with open(os.getcwd()+"/data/"+filename,encoding="utf-8",mode="a+") as f:
        yaml.safe_dump(data,stream=f)
#读取
def read_yaml(filename,key):
    with open(os.getcwd()+"/data/"+filename,encoding="utf-8",mode="r") as f:
        data = yaml.safe_load(f)
        return data[key]

#清空
def clear_yaml(filename):
    with open(os.getcwd()+"/data/"+filename,encoding="utf-8",mode="w") as f:
        f.truncate()